package com.jzr.board.ui.adapter

import android.graphics.Color
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.cardview.widget.CardView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.jzr.board.R
import com.jzr.board.bean.CareLabelListBean


class CareLabelAdapter(data: MutableList<CareLabelListBean.DataBean>?) :
    BaseQuickAdapter<CareLabelListBean.DataBean, BaseViewHolder>(
        R.layout.item_carelabel,
        data
    ) {



    override fun convert(helper: BaseViewHolder?, item: CareLabelListBean.DataBean?) {

        helper?.setText(R.id.tvName,item?.labelName)
        val rlItem = helper?.getView<CardView>(R.id.rlItem)
        val tvName = helper?.getView<TextView>(R.id.tvName)
        rlItem?.setBackgroundColor(Color.parseColor(item?.bgColor))
        tvName?.setTextColor(Color.parseColor(item?.fontColor))
        helper?.itemView?.setOnClickListener{
            if(onItemClick!=null){
                onItemClick?.onListItemClick(item)
            }
        }
    }

    private var onItemClick: onListItemClick? = null

    interface onListItemClick {
        fun onListItemClick(item: CareLabelListBean.DataBean?)
    }

    fun onListItemClick(onListItemClick: onListItemClick?) {
        this.onItemClick = onListItemClick
    }


}